#include <iostream>
#include <string>

using namespace std;

void SWAP( float *ptr_x, float *ptr_y );
void SWAP( float &x, float &y );
void SWAP( string  &x, string &y );

int main( )
{
	float x, y;
	float *ptr_x, *ptr_y;
	string str_x, str_y;

	cout << "Enter two floats to swap: " << endl;
	cin >> x >> y;

	ptr_x = &x;
	ptr_y = &y;

	SWAP( ptr_x, ptr_y );

	cout << "The floats X and Y after swap with pointers: " << x << y << endl;

	SWAP( x, y );

	cout << "The floats X and Y after swap with references: " << x << y << endl;

	cout << "Enter two strings to swap: " << endl;
	cin >> str_x >> str_y;

	SWAP( str_x, str_y );
	cout << "The strings after swap: " << str_x << str_y << endl;

	cin.get();
	cin.get();
	return 0;
}




void SWAP( float *ptr_x, float *ptr_y )
{
	float temp;

	temp = *ptr_x;
	*ptr_x = *ptr_y;
	*ptr_y = temp;
}

void SWAP( float &x, float &y )
{
	float temp;

	temp = x;
	x = y;
	y = temp;
}

void SWAP( string &x, string &y )
{
	string temp;
	temp = x;
	x = y;
	y = temp;
}
